﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BXH.Movie
{
    public class UControlCacheHelper
    {
        private static Dictionary<string, UserControl> UserControlCache = new Dictionary<string, UserControl>();
        public static T GetUControl<T>()
        where T : UserControl, new()
        {
            T uControl;
            var type = typeof(T);
            if (UserControlCache.ContainsKey(type.Name))
            {
                uControl = UserControlCache[type.Name] as T;
            }
            else
            {
                uControl = new T();
                UserControlCache[type.Name] = uControl;
            }
            return uControl;

        }
    }
}
